
#include <iostream>
#include <ctime>
#include <queue>
#include <string>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>

#ifdef WIN32
#include <windows.h>
#include <io.h>
#include <conio.h>
#endif

#ifdef _LINUX_
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#endif

#include "kernel.h"

#include "osp_common_def.h"
#include "ic/include/debug_center_inc.h"
#include "util/util.h"
#include "root.h"
#include "icli.h"

using namespace std;

void CMD_AdpRun()
{
	extern char *SYSMNG_GetSysname();
	extern ULONG SYSMNG_IsCfgRecoverOver();
	
	CliCtx ctx = {0};
	ctx.userInfo = MID_CMD;
	ctx.isCfgRecoverOver = (pfCmdIsCfgRecoverOver)SYSMNG_IsCfgRecoverOver;
	ctx.getSysname = SYSMNG_GetSysname;
	ctx.dbgPrint = (pfCmdDbgPrintFunc)debugcenter_print;
	ctx.logPrint = (pfCmdLogFunc)write_log;
	ctx.sleep = OS_sleep;
	ctx.getchar = OS_getchar;
	ctx.send = OS_send;
	ctx.recv = OS_recv;
	(VOID)cmd_init(&ctx);
}

int CMD_ADP_Init()
{
	CMD_AdpRun();

	cmd_reg_base_cmd();

	(VOID)DEBUG_PUB_RegModuleDebugs(MID_CMD, "cli", "Command line interface");

	return 0;
}

APP_INFO_S g_CMDAppInfo =
{
	MID_CMD,
	"Command",
	CMD_ADP_Init,
	cmd_main_entry
};

void Cmd_RegAppInfo()
{
	APP_RegistInfo(&g_CMDAppInfo);
}
